home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / Additions ƒ / RenderPageMessage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-14  |  3.1 KB  |  106 lines  |  [TEXT/MPS ]

  1. /* ------------------------------------------------------------------------------
  2.  
  3.     FILENAME
  4.         RenderPageMessage.c
  5.  
  6.     DESCRIPTION
  7.         This file contains the message procedure that will be invoked when the Printing Manager
  8.         issues the RenderPage message.  The routine which is called is RenderPageMessageProc.
  9.         Depending upon the effects the user selected in the Addition's Print dialog panel, 
  10.         RenderPageMessageProc will invoke routines in the Additions.c file to produce the
  11.         desired effects.
  12.  
  13.     COPYRIGHT
  14.         Copyright Apple Computer, Inc. 1991 - 1996
  15.         All rights reserved. 
  16.     
  17.     INTERFACE ROUTINES
  18.         RenderPageMessageProc
  19.  
  20.     MODIFICATION HISTORY
  21.         05/15/91            ALA        Initial Implementation
  22.          6/14/96            cn            Updated to support Universal Interfaces 2.1.
  23.  
  24.  
  25. ------------------------------------------------------------------------------- */
  26.  
  27. #include <Types.h>
  28. #include <Quickdraw.h>
  29. #include <Memory.h>
  30. #include <Resources.h>
  31. #include <Dialogs.h>
  32. #include <TextEdit.h>
  33. #include <OSUtils.h>
  34. #include <Packages.h>
  35. #include <ToolUtils.h>
  36. #include <Menus.h>
  37. #include <String.h>
  38. #include <Strings.h>
  39. #include <Printing.h>
  40.  
  41. #include <GXGraphics.h>
  42. #include <GraphicsLibraries.h>
  43. #include <FontLibrary.h>
  44.  
  45. #include <Collections.h>
  46. #include <GXMessages.h>
  47.  
  48. #include    <GXPrinting.h>
  49.  
  50. #include "Utilities.h"
  51. #include "Additions.h"
  52.  
  53.  
  54. /*================================== MESSAGE INTERFACE ROUTINES ==================================*/
  55.  
  56.  
  57. /* ===== RenderPageMessageProc =====
  58.  
  59.     RenderPageMessageProc is the extension's routine which will be invoked when Printing issues a 
  60.     renderPage message.  This routine checks to see if a serial number should be added
  61.     to the page. If so, it will call SerializeCopies to generate and add a serial number shape
  62.     to the page.  Regardless of whether a serial number is added to the page, the routine calls
  63.     Forward_RenderPage to render the page.
  64. */
  65. OSErr RenderPageMessageProc(            //    (out)    Error code
  66.     gxFormat                theFormat,            //    (in)    Format reference for the page being rendered
  67.     gxShape                thePage,                //    (in)    The page shape being rendered
  68.     gxPageInfoRecord    *pageInfo,            //    (in)    page info. describing the page
  69.     void                    *imageData)            //    (in)    image data generated
  70. {
  71.     OSErr                         anErr = noErr;
  72.     Collection                    jobCollection;
  73.     AdditionsCollection        additionsConfig;
  74.     
  75.     /* Get reference to the print Job's collection */
  76.     jobCollection = GXGetJobCollection(GXGetJob());
  77.     
  78.     /* Fetch a handle to the Additions's collection we created at Print dialog time */
  79.     anErr = GetCollectionItem (jobCollection,
  80.                                         kAdditionsCollectionType,
  81.                                         gxPrintingTagID,
  82.                                         nil,
  83.                                         &additionsConfig);
  84.     if (anErr == noErr)
  85.     {
  86.         /* If we're serializing copies, add the serial number to the page shape */
  87.         if (additionsConfig.serializeCopies)
  88.         {
  89.             SerializeCopies(    thePage, 
  90.                                     theFormat, 
  91.                                     pageInfo->copyNum, 
  92.                                     &pageInfo->pageChanged, 
  93.                                     additionsConfig.nextEndSerialNum,
  94.                                     GetCopiesFromJob(jobCollection));
  95.         }
  96.     }
  97.     else    // T => no config; don't do anything
  98.         anErr = noErr;
  99.  
  100.     /* Pass the render page message on to others */
  101.     anErr = Forward_GXRenderPage (theFormat, thePage, pageInfo, imageData);
  102.  
  103.     return(anErr);
  104. }
  105. /* RenderPageMessageProc */
  106.